<%@ page pageEncoding="utf-8"%>
<%request.setCharacterEncoding("utf-8");%>
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ include file="/include/filepath.jsp"%>
<%@ include file="/include/pageexpires.jsp" %>
<%@include file="/include/currentuserinfo.jsp"%>
<html>
  <head>
    <title>修改密码</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
   <link type="text/css" rel="stylesheet" href="<%=ctxpath%>/themes/newstyle/styles/mac/macmenu.css" id="menuStyleSheet">
  </head>
  <script language="javascript">
  function closechangepassword(){
  window.opener.document.location.reload();
  window.close();
}
     function httpRequestCheck(){
      if(form1.passwordold.value == ''){
       alert("原密码不能为空！");
       form1.passwordold.focus();
       return false;
      }
     var req;
      var url = '<%=ctxpath%>/chat/ajaxcheck.do?method=checkloginname&passwordold='+form1.passwordold.value;
     if (window.XMLHttpRequest) {
         req = new XMLHttpRequest();
     }else if (window.ActiveXObject) {
         req = new ActiveXObject("Microsoft.XMLHTTP");
     }
    if(req){
          req.onreadystatechange=function() {  
           if (req.readyState==4 && req.status==200) {//判断状态，4是已发送，200已完成  
             var  nickName = req.responseText;
             if(nickName != '0'){
              document.getElementById("passwordname").innerHTML = "原密码正确、允许修改";
             }else{
              document.getElementById("passwordname").innerHTML = "原密码不正确！";
             }
         }else{
          document.getElementById("passwordname").innerHTML = "检验中.....";
         }
         }
        req.open("post", url, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setRequestHeader("Content-Type","text/html");  
        req.setRequestHeader("Content-Type","utf-8");  
        req.send(null);  
     }	
 
 }
 function change(){
  if(form1.loginname.value == ''){
   alert("登陆名字不能为空！");
   form1.loginname.focus();
 }else if(form1.passwordold.value == ''){
   alert("原密码不能为空！");
   form1.passwordold.focus();
 }else if(form1.password1.value == ''){
   alert("新密码不能为空！");
   form1.password1.focus();
 }else if(form1.password2.value == ''){
   alert("确认密码不能为空！");
   form1.password2.focus();
 }else if(form1.password1.value != form1.password2.value){
   alert("新密码和确认密码必须一致！");
   form1.password1.focus();
 }else {
 
    var req;
  if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
     }else if (window.ActiveXObject) {
         req = new ActiveXObject("Microsoft.XMLHTTP");
     }
    if(req){
          req.onreadystatechange=function() {  
           if (req.readyState==4 && req.status==200) {//判断状态，4是已发送，200已完成  
             var  nickName = req.responseText;
             if(nickName != '0'){
              alert("密码修改成功，请记住新密码");
             }else{
              alert("密码修改失败");
             }
         }
         }
        req.open("post", '<%=ctxpath%>/chat/ajaxcheck.do?method=changepassword&passwordold='+form1.passwordold.value+'&password1='+form1.password1.value, true);
        req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setRequestHeader("Content-Type","text/html");  
        req.setRequestHeader("Content-Type","utf-8");  
        req.send(null);  
     }	
 
 }
 }
 //onbeforeunload="window.opener.document.location.reload()"
  </script>
  <body scroll="no" id="body" >
    <table id="display" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
      <tr>
        <td valign="top">
          <div id="layer1" style="width:100%; height:100%; z-index:50; overflow: auto;">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
              <tr>
                <td valign="top" align="center">
                  <table cellspacing="0" cellpadding="0" class="labeltable_middle">
                    <tr>
                      <td class="labeltd_middle">
                        
                        <form  name="form1" action="/chat/ajaxcheck.do" method="post" >
                          <table class="labeltable_middle_table">
                            <tr>
                              <td  class="labeltable_middle_td_01"  align="center" colspan="3"> 
                                修改用户登陆密码
                              </td>
                            </tr>
                            <tr>
                              <td  class="labeltable_middle_td_01" >登陆名字：</td>
                              <td><input type="text" name="loginname" value="<%=userloginname%>" readonly></td>
                              <td  class="labeltable_middle_td_01" >登陆名字 是唯一的</td>
                            </tr>
                            <tr>
                              <td  class="labeltable_middle_td_01" >原 密 码：</td>
                              <td><input type="password" name="passwordold"><input type="button" value="检验" onclick="httpRequestCheck()"></td>
                              <td  class="labeltable_middle_td_01" >
                                <div id="passwordname">密码必须跟登陆时保持一致</div>
                              </td>
                            </tr>
                            <tr>
                              <td  class="labeltable_middle_td_01" >新的密码:</td>
                              <td><input type="password" name="password1"></td>
                              <td  class="labeltable_middle_td_01" >请记住！</td>
                            </tr>
                            <tr>
                              <td  class="labeltable_middle_td_01" >确认密码:</td>
                              <td ><input type="password" name="password2"></td>
                              <td  class="labeltable_middle_td_01" >二次输入必须一致</td>
                            </tr>
                            <tr>
                              <td  class="labeltable_middle_td_01"  align="center" colspan="3"> 
                                <input type="button" value="提交" onclick="change()">
                                <input type="button" value="关闭"  onclick="closechangepassword();"/>
                              </td>
                            </tr>
                          </table>
                        </form>
                        
                      </td>
                    </tr>
                  </table>   
                  <table border="0" cellpadding="0" cellspacing="0" class="labeltable_bottom">
                    <tr>
                      <td class="left">&nbsp;</td>
                      <td class="center">&nbsp;</td>
                      <td class="right">&nbsp;</td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </td>
      </tr>
    </table>
  </body>
</html>








